package happy.robot;

import happy.robot.entity.Remark;
import happy.robot.mapper.RemarkMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by wang on 17-11-26.
 */
public class HistoryController implements Controller {

    @Autowired
    private RemarkMapper remarkMapper;

    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        ModelAndView mv = new ModelAndView();
        Long customerId = Long.parseLong(httpServletRequest.getParameter("customer"));
        List<Remark> remarks = remarkMapper.selectByCustomerIdDesc(customerId);
        mv.addObject("remarks", remarks);
        mv.setViewName("remarks");
        return mv;
    }
}
